//
//  main.cpp
//  指针数组
//
//  Created by linjinzhu on 2017/7/11.
//  Copyright © 2017年 linjinzhu. All rights reserved.
//

#include <iostream>

using namespace std;

extern void pIntArray();// 整型指针数组
extern void pStrArray();// 字符串指针数组


int main(int argc, const char * argv[]) {

    pIntArray();
    cout << "========" << endl;
    pStrArray();

    return 0;
}

const int MAX = 3;

void pIntArray() {

    int arr[MAX] = {1,5,2};
    int *pArr[MAX];

    for (int i=0; i<MAX; i++) {
        pArr[i] = &arr[i];
    }

    for (int i=0; i<MAX; i++) {
        cout << "pArr[" << i << "] = " << *pArr[i] << endl;
        cout << "pArr[" << i << "] = " << pArr[i] << endl;
    }
}

void pStrArray() {
    string str[MAX] = {"linjinzhu", "luorui", "linyimeng"};
    char *names[MAX] = {"linjinzhu", "luorui", "linyimeng"};

    for (int i=0; i<MAX; i++) {
        cout << names[i] << endl;
        cout << str[i] << endl;
    }

}
